<%@ page language="java" contentType="text/html; charset=utf-8" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%@ page import="weaver.common.DateUtil" %>
<%@ page import="weaver.general.Util" %>
<%
   
    String fullDate = DateUtil.getFullDate();
    String formid = "129";
    out.println("");
    out.println( ">>>>WeaSwlccqCronJob>>>>>fullDate="+fullDate );
    //公文类型为阅件,获取超时30天的数据
    rs.execute("select a.requestid,a.sfrq,(datediff(day,a.sfrq,getdate())-30) as csts from formtable_main_"+formid+" a " +
            "join workflow_requestbase b on a.requestid=b.requestid" +
            " where b.currentnodetype<3 and lx=0 and datediff(day,a.sfrq,getdate())>=30");
    int csts_counts = rs.getCounts();
    int csts_count = 0;
    while (rs.next()){
        String requestid = Util.null2String(rs.getString("requestid"));
        String csts = Util.null2String(rs.getString("csts"));
        String sql ="update formtable_main_"+formid+" set csts="+csts+" where requestid="+requestid;
        out.println( ">>>>WeaSwlccqCronJob>>>>csts>>>>>sql="+sql );
        boolean isUpdate = rs.execute(sql);
        if (isUpdate) {
            csts_count++;
        }
    }
    out.println( ">>>>WeaSwlccqCronJob>>>>>banjian>>>>csts_counts="+csts_counts+",csts_count="+csts_count );
    //公文类型为办件，获取剩余天数数据
    rs.execute("select a.requestid,a.sbrq,datediff(day,getdate(),a.sbrq) as sytshj,a.syts from formtable_main_"+formid+" a " +
            "join workflow_requestbase b on a.requestid=b.requestid" +
            " where b.currentnodetype<3 and lx=1 and a.sbrq>=getdate()");
    while (rs.next()){
        String requestid = Util.null2String(rs.getString("requestid"));
        String sytshj = Util.null2String(rs.getString("sytshj"));
        String syts = Util.null2String(rs.getString("syts"));
        String sql="";
        if("".equals(syts)){
            sql ="update formtable_main_"+formid+" set syts="+sytshj+" where requestid="+requestid;
        }else {
            sql ="update formtable_main_"+formid+" set syts=cast(syts as decimal(18,1))-0.5 where requestid="+requestid;
        }
        boolean isUpdate = rs.execute(sql);
        out.println( ">>>>WeaSwlccqCronJob>>>>>status="+isUpdate+">>>>>sql="+sql );
    }

    //公文类型为办件，获取已超期天数数据
    rs.execute("select a.requestid,a.sbrq,a.ycqts from formtable_main_"+formid+" a " +
            "join workflow_requestbase b on a.requestid=b.requestid" +
            " where b.currentnodetype<3 and lx=1 and a.sbrq<getdate()");
    while (rs.next()){
        String requestid = Util.null2String(rs.getString("requestid"));
        String ycqts = Util.null2String(rs.getString("ycqts"));
        String sql="";
        if("".equals(ycqts)){ 
            sql ="update formtable_main_"+formid+" set syts=null,ycqts=0.5 where requestid="+requestid;
        }else {
            sql ="update formtable_main_"+formid+" set ycqts=cast(ycqts as decimal(18,1))+0.5 where requestid="+requestid;
        }
        boolean isUpdate = rs.execute(sql);
        out.println( ">>>>WeaSwlccqCronJob>>>>>status="+isUpdate+">>>>>sql="+sql );
    }
%>
